local card_extension = Package:new("zhonger_heg_cards", Package.CardPack)
card_extension.extensionName = "zhonger_heg"
card_extension.game_modes_whitelist = {"zhonger_heg_mode"}

local extension = Package:new("zhonger_heg_generals")
extension.extensionName = "zhonger_heg"
extension.game_modes_whitelist = {"zhonger_heg_mode"}

Fk:loadTranslationTable{
  ["zhonger_heg_cards"] = "中二国战",
  ["zhonger_heg_generals"] = "标准包",

  ["zhonger_st_heg"] = "标"
}

local U = require "packages/utility/utility"
local H = require "packages/hegemony/util"

local standard_cards = require "packages/hegemony/hegemony_cards"
local strategic_advantage = require "packages/hegemony/strategic_advantage"
local formation_cards = require "packages/hegemony/formation"[2]
local momentum_cards = require "packages/hegemony/momentum"[2]
local transformation_cards = require "packages/hegemony/transformation"[2]
local power_cards = require "packages/hegemony/power"[2]

local card_packs = {standard_cards, strategic_advantage, formation_cards, momentum_cards, transformation_cards, power_cards}

local ban_cards = {"double_swords", "jingfan","six_swords", "zhuahuangfeidian"}

for _, extension in ipairs(card_packs) do
  for _, card in ipairs(extension.cards) do
    if not table.contains(ban_cards, card.name) then
      local c = Fk:cloneCard(card.name, card.suit, card.number)
      card_extension:addCard(c)
      if table.contains(H.allianceCards, card) then
        table.insert(H.allianceCards, c)
      end
    end
  end
end

local caocao = General(extension, "zhonger_st_heg__caocao", "wei", 4)
local jianxiong = fk.CreateTriggerSkill{
  name = "fk_jianxiong",
  anim_type = "masochism",
  events = {fk.Damaged},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self)
  end,
  on_cost = function(self, event, target, player, data)
    local choices = {'fk_jianxiong_draw'}
    if data.card and target.room:getCardArea(data.card) == Card.Processing then
      table.insert(choices, 'fk_jianxiong_get')
    end
    table.insert(choices, 'Cancel')
    local choice = player.room:askForChoice(player, choices, self.name)
    if choice ~= "Cancel" then
      self.cost_data = choice
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    if self.cost_data == "fk_jianxiong_draw" then
      player:drawCards(1, self.name)
    elseif self.cost_data == "fk_jianxiong_get" then
      player.room:obtainCard(player.id, data.card, true, fk.ReasonJustMove)
    end
  end,
}
caocao:addSkill(jianxiong)
caocao:addCompanions({"zhonger_st_heg__dianwei", "zhonger_st_heg__xuchu"})
Fk:loadTranslationTable{
  ["zhonger_st_heg__caocao"] = "曹操",
  ["#zhonger_st_heg__caocao"] = "魏武帝",
  ["illustrator:zhonger_st_heg__caocao"] = "青骑士",
  ["$fk_jianxiong1"] = "宁教我负天下人，休教天下人负我！",
  ["$fk_jianxiong2"] = "吾好梦中杀人！",
  ['fk_jianxiong'] = '奸雄',
  [':fk_jianxiong'] = '当你受到伤害后，你可以获得对你造成伤害的牌或摸一张牌。',
  ['fk_jianxiong_draw'] = '摸一张牌',
  ['fk_jianxiong_get'] = '获得对你造成伤害的牌',
  ["~zhonger_st_heg__caocao"] = "狐死归首丘，故乡安可忘……",
}

local simayi = General(extension, "zhonger_st_heg__simayi", "wei", 3)
simayi:addSkill("fankui")
simayi:addSkill("ex__guicai") -- 手杀
Fk:loadTranslationTable{
  ["zhonger_st_heg__simayi"] = "司马懿",
  ["#zhonger_st_heg__simayi"] = "狼顾之鬼",
  ["illustrator:zhonger_st_heg__simayi"] = "木美人",
  ["~zhonger_st_heg__simayi"] = "我的气数就到这里了吗？",
}

local xiahoudun = General(extension, "zhonger_st_heg__xiahoudun", "wei", 4)
xiahoudun:addSkill("hs__ganglie")
xiahoudun:addCompanions("zhonger_st_heg__xiahouyuan")
Fk:loadTranslationTable{
  ["zhonger_st_heg__xiahoudun"] = "夏侯惇",
  ["#zhonger_st_heg__xiahoudun"] = "独眼的罗刹",
  ["illustrator:zhonger_st_heg__xiahoudun"] = "DH",
  ["$hs__ganglie1"] = "鼠辈，竟敢伤我！",
  ["$hs__ganglie2"] = "以彼之道，还施彼身！",
  ["~zhonger_st_heg__xiahoudun"] = "诸多败绩，有负丞相重托……",
}

local zhangliao = General(extension, "zhonger_st_heg__zhangliao", "wei", 4)
zhangliao:addSkill("ex__tuxi") -- 手杀
Fk:loadTranslationTable{
  ["zhonger_st_heg__zhangliao"] = "张辽",
  ["#zhangliao"] = "前将军",
  ["illustrator:zhangliao"] = "张帅",
  ["~zhonger_st_heg__zhangliao"] = "被敌人占了先机……呃……",
}

local xuchu = General(extension, "zhonger_st_heg__xuchu", "wei", 4)

xuchu:addSkill("hs__luoyi")
Fk:loadTranslationTable{
  ["zhonger_st_heg__xuchu"] = "许褚",
  ["#xuchu"] = "虎痴",
  ["$hs__luoyi1"] = "脱！",
  ["$hs__luoyi2"] = "谁来与我大战三百回合？",
  ["illustrator:xuchu"] = "KayaK",
  ["~zhonger_st_heg__xuchu"] = "冷……好冷啊……",
}

local guojia = General(extension, "zhonger_st_heg__guojia", "wei", 3)
guojia:addSkill("hs__yiji")
guojia:addSkill("tiandu")
Fk:loadTranslationTable{
  ["zhonger_st_heg__guojia"] = "郭嘉",
  ["#zhonger_st_heg__guojia"] = "早终的先知",
  ["illustrator:zhonger_st_heg__guojia"] = "绘聚艺堂",
  ["~zhonger_st_heg__guojia"] = "咳，咳……",
}

local zhenji = General(extension, "zhonger_st_heg__zhenji", "wei", 3, 3, General.Female)
zhenji:addSkill("hs__luoshen")
zhenji:addSkill("qingguo")
zhenji:addCompanions("zhonger_st_heg__caopi")

Fk:loadTranslationTable{
  ["zhonger_st_heg__zhenji"] = "甄姬",
  ["#zhonger_st_heg__zhenji"] = "薄幸的美人",
  ["illustrator:zhonger_st_heg__zhenji"] = "DH",
  ["~zhonger_st_heg__zhenji"] = "悼良会之永绝兮，哀一逝而异乡。",
}

local xiahouyuan = General(extension, "zhonger_st_heg__xiahouyuan", "wei", 4)
xiahouyuan:addSkill("hs__shensu")
Fk:loadTranslationTable{
  ["zhonger_st_heg__xiahouyuan"] = "夏侯渊",
  ["#zhonger_st_heg__xiahouyuan"] = "疾行的猎豹",
  ["illustrator:zhonger_st_heg__xiahouyuan"] = "KayaK",
  ["~zhonger_st_heg__xiahouyuan"] = "我的速度…还是不够……",
}

local zhanghe = General(extension, "zhonger_st_heg__zhanghe", "wei", 4)
zhanghe:addSkill("qiaobian")
Fk:loadTranslationTable{
  ["zhonger_st_heg__zhanghe"] = "张郃",
  ["#zhonger_st_heg__zhanghe"] = "料敌机先",
  ["illustrator:zhonger_st_heg__zhanghe"] = "张帅",
  ["~zhonger_st_heg__zhanghe"] = "呃，膝盖中箭了……",
}

local xuhuang = General(extension, "zhonger_st_heg__xuhuang", "wei", 4)
xuhuang:addSkill("m_ex__duanliang")

Fk:loadTranslationTable{
  ["zhonger_st_heg__xuhuang"] = "徐晃",
  ["#zhonger_st_heg__xuhuang"] = "周亚夫之风",
  ["illustrator:zhonger_st_heg__xuhuang"] = "官方",
  ["~zhonger_st_heg__xuhuang"] = "敌军防备周全，是吾轻敌……",
}

local caoren = General(extension, "zhonger_st_heg__caoren", "wei", 4)
local jushou_select = fk.CreateActiveSkill{
  name = "#zhonger_st_heg__jushou_select",
  can_use = Util.FalseFunc,
  target_num = 0,
  card_num = 1,
  card_filter = function(self, to_select, selected)
    if #selected == 0 and Fk:currentRoom():getCardArea(to_select) ~= Card.PlayerEquip then
      local card = Fk:getCardById(to_select)
      if card.type == Card.TypeEquip then
        return not Self:prohibitUse(card)
      else
        return not Self:prohibitDiscard(card)
      end
    end
  end,
}
local jushou = fk.CreateTriggerSkill{
  name = "zhonger_st_heg__jushou",
  anim_type = "defensive",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Finish
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local num = 0
    for _, v in pairs(H.getKingdomPlayersNum(room)) do
      if v and v > 0 then
        num = num + 1
      end
    end
    local o = 0
    if num > 2 then
      o = 4
    else
      o = 2
    end
    room:drawCards(player, o, self.name)
    if player.dead then return false end
    local jushou_card
    for _, id in pairs(player:getCardIds(Player.Hand)) do
      local card = Fk:getCardById(id)
      if (card.type == Card.TypeEquip and not player:prohibitUse(card)) or (card.type ~= Card.TypeEquip and not player:prohibitDiscard(card)) then
        jushou_card = card
        break
      end
    end
    if not jushou_card then return end
    local _, ret = room:askForUseActiveSkill(player, "#zhonger_st_heg__jushou_select", "#zhonger_st_heg__jushou-select", false)
    if ret then
      jushou_card = Fk:getCardById(ret.cards[1])
    end
    if jushou_card then
      if jushou_card.type == Card.TypeEquip then
        room:useCard({
          from = player.id,
          tos = {{player.id}},
          card = jushou_card,
        })
      else
        room:throwCard(jushou_card:getEffectiveId(), self.name, player, player)
      end
    end
    if player.dead then return false end
    if o > 2 then player:turnOver() end
  end,
}
jushou:addRelatedSkill(jushou_select)
caoren:addSkill(jushou)

Fk:loadTranslationTable{
  ["zhonger_st_heg__caoren"] = "曹仁",
  ["#zhonger_st_heg__caoren"] = "大将军",
  ["illustrator:zhonger_st_heg__caoren"] = "Ccat",
  ["zhonger_st_heg__jushou"] = "据守",
  [":zhonger_st_heg__jushou"] = "结束阶段，你可摸四张牌（若势力数不大于2则改为两张），然后弃置一张手牌，若以此法弃置的牌为装备牌，则改为你使用之。若你此次摸牌数大于2，则你将武将牌叠置。",

  ["#zhonger_st_heg__jushou_select"] = "据守",
  ["#zhonger_st_heg__jushou-select"] = "据守：选择使用手牌中的一张装备牌或弃置手牌中的一张非装备牌",

  ["$zhonger_st_heg__jushou1"] = "我先休息一会儿！",
  ["$zhonger_st_heg__jushou2"] = "尽管来吧！",
  ["~zhonger_st_heg__caoren"] = "实在是守不住了……",
}

local dianwei = General(extension, "zhonger_st_heg__dianwei", "wei", 5)

dianwei:addSkill("qiangxi")
Fk:loadTranslationTable{
  ['zhonger_st_heg__dianwei'] = '典韦',
  ["#zhonger_st_heg__dianwei"] = "古之恶来",
  ["illustrator:zhonger_st_heg__dianwei"] = "小冷",
  ["~zhonger_st_heg__dianwei"] = "主公，快走！",
}

local xunyu = General(extension, "zhonger_st_heg__xunyu", "wei", 3)
local zhonger_st_heg__jieming = fk.CreateTriggerSkill{
  name = "zhonger_st_heg__jieming",
  anim_type = "masochism",
  events = {fk.Damaged},
  on_trigger = function(self, event, target, player, data)
    self.cancel_cost = false
    for i = 1, data.damage do
      if self.cancel_cost or player.dead then break end
      self:doCost(event, target, player, data)
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local to = room:askForChoosePlayers(player, table.map(room.alive_players, Util.IdMapper), 1, 1, "#zhonger_st_heg__jieming-choose", self.name, true)
    if #to > 0 then
      self.cost_data = to[1]
      return true
    end
    self.cancel_cost = true
  end,
  on_use = function(self, event, target, player, data)
    local to = player.room:getPlayerById(self.cost_data)
    to:drawCards(2, self.name)
    if to.dead then return false end
    local x = #to.player_cards[Player.Hand] - math.min(to.maxHp, 5)
    if x > 0 then
      player.room:askForDiscard(to, x, x, false, self.name, false, ".", "#zhonger_st_heg__jieming-discard:::"..x)
    end
    local num = math.min(to.maxHp, 5) - to:getHandcardNum()
    if num > 0 then
      to:drawCards(num, self.name)
    end
  end,
}
xunyu:addSkill("quhu")
xunyu:addSkill(zhonger_st_heg__jieming)
Fk:loadTranslationTable{
  ['zhonger_st_heg__xunyu'] = '荀彧',
  ["#zhonger_st_heg__xunyu"] = "王佐之才",
  ["illustrator:zhonger_st_heg__xunyu"] = "青岛磬蒲",
  ["zhonger_st_heg__jieming"] = "节命",
  [":zhonger_st_heg__jieming"] = "当你受到1点伤害后，你可令一名角色摸两张牌，其将手牌调整至X张。（X为其体力上限且至多为5）",
  ["#zhonger_st_heg__jieming-choose"] = "节命：你可以令一名角色摸两张牌并将手牌调整至X张（X为其体力上限且至多为5）",
  ["#zhonger_st_heg__jieming-discard"] = "节命：选择%arg张手牌弃置",
  ["$zhonger_st_heg__jieming1"] = "秉忠贞之志，守谦退之节。",
  ["$zhonger_st_heg__jieming2"] = "我，永不背弃。",
  ["~zhonger_st_heg__xunyu"] = "主公要臣死，臣不得不死。",
}

local caopi = General(extension, "zhonger_st_heg__caopi", "wei", 3)
caopi:addSkill("xingshang")
caopi:addSkill("m_ex__fangzhu")

Fk:loadTranslationTable{
  ['zhonger_st_heg__caopi'] = '曹丕',
  ["#zhonger_st_heg__caopi"] = "霸业的继承者",
  ["illustrator:zhonger_st_heg__caopi"] = "DH",
  ["~zhonger_st_heg__caopi"] = "子建，子建……",
}

local yuejin = General(extension, "zhonger_st_heg__yuejin", "wei", 4)
yuejin:addSkill("xiaoguo")

Fk:loadTranslationTable{
  ["zhonger_st_heg__yuejin"] = "乐进",
  ["#zhonger_st_heg__yuejin"] = "奋强突固",
  ["illustrator:zhonger_st_heg__yuejin"] = "巴萨小马",
  ["desinger:zhonger_st_heg__yuejin"] = "淬毒",
  ["~zhonger_st_heg__yuejin"] = "箭疮发作，吾命休矣。",
}

local liubei = General(extension, "zhonger_st_heg__liubei", "shu", 4)
liubei:addSkill("ex__rende")
liubei:addCompanions({"zhonger_st_heg__guanyu", "zhonger_st_heg__zhangfei", "zhonger_st_heg__ganfuren"})
Fk:loadTranslationTable{
  ["zhonger_st_heg__liubei"] = "刘备",
  ["#zhonger_st_heg__liubei"] = "乱世的枭雄",
  ["illustrator:zhonger_st_heg__liubei"] = "木美人",
  ["~zhonger_st_heg__liubei"] = "汉室未兴，祖宗未耀，朕实不忍此时西去……",
}

local guanyu = General(extension, "zhonger_st_heg__guanyu", "shu", 5)
local fuck = fk.CreateTriggerSkill{
  name = "fuck",
  anim_type = "offensive",
  events = {fk.EventPhaseEnd},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) then
      local room = player.room
      local events = room.logic:getEventsOfScope(GameEvent.Death, 999, function(e)
        local deathStruct = e.data[1]
        return deathStruct.damage and deathStruct.damage.from and deathStruct.damage.from == player
      end, Player.HistoryPhase)
      return #events > 0
    end
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#fuck-invoke")
  end,
  on_use = function(self, event, target, player, data)
    player:gainAnExtraPhase(True)
  end,
}
guanyu:addSkill("wusheng")
guanyu:addSkill(fuck)
Fk:loadTranslationTable{
  ["zhonger_st_heg__guanyu"] = "关羽",
  ["#zhonger_st_heg__guanyu"] = "威震华夏",
  ["fuck"] = "怒斩",
  [":fuck"] = "出牌阶段结束时，若你于当前阶段杀死过角色，你执行一个额外的出牌阶段。",
  ["$fuck1"] = "以义传魂，以武入圣！",
  ["$fuck2"] = "义击逆流，武安黎庶。",
  ["illustrator:zhonger_st_heg__guanyu"] = "俊西JUNC",
  ["~zhonger_st_heg__guanyu"] = "什么？此地名叫麦城？",
}

local zhangfei = General(extension, "zhonger_st_heg__zhangfei", "shu", 4)
zhangfei:addSkill("hs__paoxiao")

Fk:loadTranslationTable{
  ["zhonger_st_heg__zhangfei"] = "张飞",
  ["#zhonger_st_heg__zhangfei"] = "万夫不当",
  ["illustrator:zhonger_st_heg__zhangfei"] = "KayaK",
  ["~zhonger_st_heg__zhangfei"] = "实在是杀不动了……",
}

local zhugeliang = General(extension, "zhonger_st_heg__zhugeliang", "shu", 3)
local kongcheng = fk.CreateTriggerSkill{
  name = "zhonger_st_heg__kongcheng",
  anim_type = "defensive",
  events = {fk.BeforeCardsMove, fk.EventPhaseStart},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return false end
    if event == fk.EventPhaseStart then
      return player == target and player.phase == Player.Draw and #player:getPile("zither") > 0
    else
      if event == fk.BeforeCardsMove then
        if player.phase ~= Player.NotActive then return false end
        for _, move in ipairs(data) do
          if move.to == player.id and move.toArea == Card.PlayerHand then
            return true
          end
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.BeforeCardsMove then
      local mirror_moves = {}
      for _, move in ipairs(data) do
        if move.moveReason == fk.ReasonGive and move.to == player.id and move.toArea == Card.PlayerHand then
          local mirror_info = move.moveInfo
          if #mirror_info > 0 then
            move.moveInfo = {}
            local mirror_move = table.clone(move)
            mirror_move.toArea = Card.PlayerSpecial
            mirror_move.specialName = "zither"
            mirror_move.moveInfo = mirror_info
            table.insert(mirror_moves, mirror_move)
          end
        end
      end
      table.insertTable(data, mirror_moves)
    else
      local dummy = Fk:cloneCard("jink")
      dummy:addSubcards(player:getPile("zither"))
      room:obtainCard(player, dummy, true)
    end
  end
}
local kongcheng2 = fk.CreateTriggerSkill{
  name = "kongcheng2",
  anim_type = "defensive",
  events = {fk.TargetConfirming},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return false end
      if not player:isKongcheng() then return false end
        if event == fk.TargetConfirming then
          return target == player and (player:hasSkill(self) and data.card.is_damage_card and #AimGroup:getAllTargets(data.tos) == 1)
        end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.TargetConfirming then
      AimGroup:cancelTarget(data, player.id)
      return true
          end
  end
}
kongcheng:addRelatedSkill(kongcheng2)
zhugeliang:addSkill("hs__guanxing")
zhugeliang:addSkill(kongcheng)
zhugeliang:addCompanions("zhonger_st_heg__huangyueying")

Fk:loadTranslationTable{
  ["zhonger_st_heg__zhugeliang"] = "诸葛亮",
  ["#zhonger_st_heg__zhugeliang"] = "迟暮的丞相",
  ["illustrator:zhonger_st_heg__zhugeliang"] = "木美人",
  ["zhonger_st_heg__kongcheng"] = "空城",
  [":zhonger_st_heg__kongcheng"] = "锁定技，当你成为伤害牌的唯一目标时，若你没有手牌，取消此目标；"..
    "你的回合外，当牌移至你的手牌区前，你将此次移动的目标区域改为你的武将牌上（均称为“琴”），摸牌阶段开始时，你获得所有“琴”。",
  ["zither"] = "琴",
  ["$zhonger_st_heg__guanxing1"] = "观今夜天象，知天下大事。",
  ["$zhonger_st_heg__guanxing2"] = "知天易，逆天难。",
  ["$zhonger_st_heg__kongcheng1"] = "淡然相对，转危为安。",
  ["$zhonger_st_heg__kongcheng2"] = "绝处逢生，此招慎用。",
  ["~zhonger_st_heg__zhugeliang"] = "将星陨落，天命难违。",
}

local zhaoyun = General(extension, "zhonger_st_heg__zhaoyun", "shu", 4)
zhaoyun:addSkill("ex__longdan")
zhaoyun:addSkill("yajiao")
zhaoyun:addCompanions("zhonger_st_heg__liushan")

Fk:loadTranslationTable{
  ["zhonger_st_heg__zhaoyun"] = "赵云",
  ["#zhonger_st_heg__zhaoyun"] = "虎威将军",
  ["illustrator:zhonger_st_heg__zhaoyun"] = "DH",
  ["~zhonger_st_heg__zhaoyun"] = "这，就是失败的滋味吗？",
}

local machao = General(extension, "zhonger_st_heg__machao", "shu", 4)
machao:addSkill("mashu")
machao:addSkill("hs__tieqi")
Fk:loadTranslationTable{
  ["zhonger_st_heg__machao"] = "马超",
  ["#zhonger_st_heg__machao"] = "一骑当千",
  ["illustrator:zhonger_st_heg__machao"] = "KayaK&木美人&张帅",
  ["~zhonger_st_heg__machao"] = "请将我，葬在西凉……",
}

local huangyueying = General(extension, "zhonger_st_heg__huangyueying", "shu", 3, 3, General.Female)
huangyueying:addSkill("jizhi")
huangyueying:addSkill("qicai")
huangyueying:addCompanions("zhonger_st_heg__wolong")

Fk:loadTranslationTable{
  ["zhonger_st_heg__huangyueying"] = "黄月英",
  ["#zhonger_st_heg__huangyueying"] = "归隐的杰女",
  ["illustrator:zhonger_st_heg__huangyueying"] = "木美人",
  ["~zhonger_st_heg__huangyueying"] = "亮……",
}

local huangzhong = General(extension, "zhonger_st_heg__huangzhong", "shu", 4)
local liegong = fk.CreateTriggerSkill{
  name = "zhonger_st_heg__liegong",
  anim_type = "offensive",
  events = {fk.TargetSpecified},
  can_trigger = function(self, event, target, player, data)
    if not (target == player and player:hasSkill(self)) then return end
    local room = player.room
    local to = room:getPlayerById(data.to)
    local num = #to:getCardIds(Player.Hand)
    local filter = num <= player:getAttackRange() or num >= player.hp
    return data.card.trueName == "slash" and filter and player.phase == Player.Play
  end,
  on_use = function(self, event, target, player, data)
    data.disresponsiveList = data.disresponsiveList or {}
    table.insert(data.disresponsiveList, data.to)
  end,
}
local liegongAR = fk.CreateAttackRangeSkill{
  name = "#zhonger_st_heg__liegongAR",
  correct_func = function(self, from, to)
    if from:hasSkill("zhonger_st_heg__liegong") then
      for _, p in ipairs(Fk:currentRoom().alive_players) do
        if string.find(p.general, "lord") and p:hasSkill("shouyue") and p.kingdom == from.kingdom then
          return 1
        end
      end
    end
    return 0
  end,
}
local liegong_t = fk.CreateTargetModSkill{
  name = "#ZE__liegong_targetmod",
    bypass_distances =  function(self, player, skill, card, target)
    if skill.trueName == "slash_skill" and player:hasSkill(liegong) then
      return card and target and player:distanceTo(target) <= card.number
    end
  end,
}
liegong:addRelatedSkill(liegongAR)
liegong:addRelatedSkill(liegong_t)
huangzhong:addSkill(liegong)
huangzhong:addCompanions("zhonger_st_heg__weiyan")
Fk:loadTranslationTable{
  ["zhonger_st_heg__huangzhong"] = "黄忠",
  ["#zhonger_st_heg__huangzhong"] = "老当益壮",
  ["illustrator:zhonger_st_heg__huangzhong"] = "匠人绘",
  ["zhonger_st_heg__liegong"] = "烈弓",
  [":zhonger_st_heg__liegong"] = "你对至其距离不大于此【杀】点数的角色使用【杀】无距离关系的限制。当你于出牌阶段内使用【杀】指定目标后，若其手牌数不小于你的体力值或不大于你的攻击范围，你可令其不能使用【闪】响应此【杀】。",
  ["$zhonger_st_heg__liegong1"] = "龙骨成镞，矢破苍穹。",
  ["$zhonger_st_heg__liegong2"] = "凤翎为羽，箭没坚城。",
  ["~zhonger_st_heg__huangzhong"] = "末将有负主公重托……",
}

local weiyan = General(extension, "zhonger_st_heg__weiyan", "shu", 4)
weiyan:addSkill("ol_ex__kuanggu")

Fk:loadTranslationTable{
  ["zhonger_st_heg__weiyan"] = "魏延",
  ["#zhonger_st_heg__weiyan"] = "嗜血的独狼",
  ["illustrator:zhonger_st_heg__weiyan"] = "瞌瞌一休",
  ["~zhonger_st_heg__weiyan"] = "奸贼……害我……",
}

local pangtong = General(extension, "zhonger_st_heg__pangtong", "shu",3)
pangtong:addSkill("lianhuan")
pangtong:addSkill("niepan")
pangtong:addCompanions("zhonger_st_heg__wolong")
Fk:loadTranslationTable{
  ['zhonger_st_heg__pangtong'] = '庞统',
  ["#zhonger_st_heg__pangtong"] = "凤雏",
  ["illustrator:zhonger_st_heg__pangtong"] = "KayaK",
  ["~zhonger_st_heg__pangtong"] = "看来我命中注定将丧命于此……",
  
}

local wolong = General(extension, "zhonger_st_heg__wolong", "shu", 3)
wolong:addSkill("bazhen")
wolong:addSkill("huoji")
wolong:addSkill("kanpo")
Fk:loadTranslationTable{
  ['zhonger_st_heg__wolong'] = '卧龙诸葛亮',
  ["#zhonger_st_heg__wolong"] = "卧龙",
  ["illustrator:zhonger_st_heg__wolong"] = "绘聚艺堂",
  ["~zhonger_st_heg__wolong"] = "我的计谋竟被……",
}

local liushan = General(extension, "zhonger_st_heg__liushan", "shu", 3)
liushan:addSkill("xiangle")
liushan:addSkill("fangquan")
Fk:loadTranslationTable{
  ['zhonger_st_heg__liushan'] = '刘禅',
  ["#zhonger_st_heg__liushan"] = "无为的真命主",
  ["illustrator:zhonger_st_heg__liushan"] = "LiuHeng",
  ["~zhonger_st_heg__liushan"] = "别打脸，我投降还不行吗？",
}

local menghuo = General(extension, "zhonger_st_heg__menghuo", "shu", 4)
local zhonger_st_heg__zaiqi = fk.CreateTriggerSkill{
  name = "zhonger_st_heg__zaiqi",
  events = {fk.EventPhaseEnd},
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(self) and player.phase == Player.Discard then
      local ids = {}
      local room = player.room
      local turn_event = room.logic:getCurrentEvent():findParent(GameEvent.Turn)
      if turn_event == nil then return false end
      U.getEventsByRule(room, GameEvent.MoveCards, 1, function (e)
        for _, move in ipairs(e.data) do
          if move.toArea == Card.DiscardPile then
            for _, info in ipairs(move.moveInfo) do
              table.insertIfNeed(ids, info.cardId)
            end
          end
        end
        return false
      end, turn_event.id)
      local x = #table.filter(ids, function (id)
        return room:getCardArea(id) == Card.DiscardPile and Fk:getCardById(id).suit == Card.Heart
      end)
      if x > 0 then
        self.cost_data = x
        return true
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local x = self.cost_data
    local result = room:askForChoosePlayers(player, table.map(room.alive_players, Util.IdMapper), 1, x,
    "#zhonger_st_heg__zaiqi-choose:::"..x, self.name, true)
    if #result > 0 then
      self.cost_data = result
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:sortPlayersByAction(self.cost_data)
    local targets = table.map(self.cost_data, function(id)
      return room:getPlayerById(id) end)
    for _, p in ipairs(targets) do
      if not p.dead then
        local choices = {"zhonger_st_heg__zaiqi_draw"}
        if player and not player.dead and player:isWounded() then
          table.insert(choices, "zhonger_st_heg__zaiqi_recover")
        end
        local choice = room:askForChoice(p, choices, self.name, "#zhonger_st_heg__zaiqi-choice:"..player.id)
        if choice == "zhonger_st_heg__zaiqi_draw" then
          p:drawCards(1, self.name)
        else
          room:recover({
            who = player,
            num = 1,
            recoverBy = p,
            skillName = self.name
          })
        end
      end
    end
  end,
}
menghuo:addCompanions("zhonger_st_heg__zhurong")
menghuo:addSkill("huoshou")
menghuo:addSkill(zhonger_st_heg__zaiqi)
Fk:loadTranslationTable{
  ['zhonger_st_heg__menghuo'] = '孟获',
  ["#zhonger_st_heg__menghuo"] = "南蛮王",
  ["zhonger_st_heg__zaiqi"] = "再起",
  [":zhonger_st_heg__zaiqi"] = "弃牌阶段结束时，你可选择至多X名角色（X为弃牌堆里于此回合内移至此区域的红桃牌数），这些角色各选择：1.令你回复1点体力；2.摸一张牌。",

  ["#zhonger_st_heg__zaiqi-choose"] = "再起：选择至多%arg名角色，这些角色各选择令你回复1点体力或摸一张牌",
  ["#zhonger_st_heg__zaiqi-choice"] = "再起：选择摸一张牌或令%src回复1点体力",
  ["zhonger_st_heg__zaiqi_draw"] = "摸一张牌",
  ["zhonger_st_heg__zaiqi_recover"] = "令其回复体力",

  ["$huoshou_zhonger_st_heg__menghuo1"] = "我才是南中之主！",
  ["$huoshou_zhonger_st_heg__menghuo2"] = "整个南中都要听我的！",
  ["$zhonger_st_heg__zaiqi1"] = "且败且战，愈战愈勇！",
  ["$zhonger_st_heg__zaiqi2"] = "若有来日，必将汝等拿下！",
  ["~zhonger_st_heg__menghuo"] = "勿再放我，但求速死……",
  ["illustrator:zhonger_st_heg__menghuo"] = "废柴男",
}

local zhurong = General(extension, "zhonger_st_heg__zhurong", "shu", 4, 4, General.Female)
zhurong:addSkill("juxiang")
zhurong:addSkill("lieren")
Fk:loadTranslationTable{
  ['zhonger_st_heg__zhurong'] = '祝融',
  ["#zhonger_st_heg__zhurong"] = "野性的女王",
  ["illustrator:zhonger_st_heg__zhurong"] = "废柴男",
  ["~zhonger_st_heg__zhurong"] = "大王，我，先走一步了。",
}

local ganfuren = General(extension, "zhonger_st_heg__ganfuren", "shu", 3, 3, General.Female)
local shenzhi = fk.CreateTriggerSkill{
  name = "zhonger_st_heg__shenzhi",
  anim_type = "support",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Start and
      player:getHandcardNum() >= player.hp and player:isWounded()
  end,
  on_cost = function(self, event, target, player, data)
    local card = player.room:askForDiscard(player, 1, 1, false, self.name, true, ".", "#zhonger_st_heg__shenzhi-invoke", true)
    if #card > 0 then
      self.cost_data = card
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:throwCard(self.cost_data, self.name, player, player)
    if not player.dead and player:isWounded() then
      room:recover({
        who = player,
        num = 1,
        recoverBy = player,
        skillName = self.name
      })
    end
  end,
}
ganfuren:addSkill("hs__shushen")
ganfuren:addSkill(shenzhi)

Fk:loadTranslationTable{
  ['zhonger_st_heg__ganfuren'] = '甘夫人',
  ["#zhonger_st_heg__ganfuren"] = "昭烈皇后",
  ["illustrator:zhonger_st_heg__ganfuren"] = "琛·美弟奇",
  ["designer:zhonger_st_heg__ganfuren"] = "淬毒",
  ["zhonger_st_heg__shenzhi"] = "神智",
  [":zhonger_st_heg__shenzhi"] = "准备阶段，若你手牌数不小于体力值，你可以弃置一张手牌并回复1点体力。",
  ["#zhonger_st_heg__shenzhi-invoke"] = "神智：你可以弃置一张手牌，回复1点体力",
  ["$zhonger_st_heg__shenzhi1"] = "子龙将军，一切都托付给你了。",
  ["$zhonger_st_heg__shenzhi2"] = "阿斗，相信妈妈，没事的。",
  ["~zhonger_st_heg__ganfuren"] = "请替我照顾好阿斗……",
}

local sunquan = General(extension, "zhonger_st_heg__sunquan", "wu", 4)
sunquan:addSkill("hs__zhiheng")
sunquan:addCompanions("zhonger_st_heg__zhoutai")

Fk:loadTranslationTable{
  ["zhonger_st_heg__sunquan"] = "孙权",
  ["#zhonger_st_heg__sunquan"] = "年轻的贤君",
  ["illustrator:zhonger_st_heg__sunquan"] = "KayaK",
  ["~zhonger_st_heg__sunquan"] = "父亲，大哥，仲谋愧矣……",
}

local ganning = General(extension, "zhonger_st_heg__ganning", "wu", 4)

ganning:addSkill("qixi")
ganning:addSkill("fenwei")

Fk:loadTranslationTable{
  ["zhonger_st_heg__ganning"] = "甘宁",
  ["#zhonger_st_heg__ganning"] = "锦帆游侠",
  ["$qixi_zhonger_st_heg__ganning1"] = "弟兄们，准备动手！",
  ["$qixi_zhonger_st_heg__ganning2"] = "你用不了这么多了！",
  ["illustrator:zhonger_st_heg__ganning"] = "KayaK",
  ["~zhonger_st_heg__ganning"] = "二十年后，又是一条好汉！",
}

local lvmeng = General(extension, "zhonger_st_heg__lvmeng", "wu", 4)
lvmeng:addSkill("hs__keji")
local botu = fk.CreateActiveSkill{
  name = "zhonger_st_heg__botu",
  anim_type = "control",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) < 1
  end,
  card_num = 0,
  card_filter = Util.FalseFunc,
  target_filter = function(self, to_select, selected)
    return #selected == 0 and to_select ~= Self.id and not Fk:currentRoom():getPlayerById(to_select):isKongcheng()
  end,
  target_num = 1,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local cids = target:getCardIds(Player.Hand)
    local card_suits = {}
    table.forEach(cids, function(id)
      table.insertIfNeed(card_suits, Fk:getCardById(id).suit)
    end)
    local num = #card_suits
    local cards, choice = U.askforChooseCardsAndChoice(player, cids, {"zhonger_st_heg__botu_discard", "zhonger_st_heg__botu_put"}, self.name, "#zhonger_st_heg__botu-ask::" .. target.id, {"Cancel"})
    if #cards == 0 then return end
    target:showCards(cards)
    if choice == "zhonger_st_heg__botu_discard" then
      room:throwCard(cards, self.name, target, player)
    else
      room:moveCardTo(cards, Card.DrawPile, nil, fk.ReasonPut, self.name, nil, false)
    end
    card_suits = {}
    cids = target:getCardIds(Player.Hand)
    table.forEach(cids, function(id)
      table.insertIfNeed(card_suits, Fk:getCardById(id).suit)
    end)
    local num2 = #card_suits
    if num > num2 and not player.dead and not target.dead then
      room:setPlayerMark(target, "@@zhonger_st_heg__botu_dr-turn", 1)
      room:setPlayerMark(player, "_zhonger_st_heg__botu-turn", 1)
    end
  end,
}
local zhonger_st_heg__botu_dr = fk.CreateTriggerSkill{
  name = "#zhonger_st_heg__botu_dr",
  mute = true,
  frequency = Skill.Compulsory,
  events = {fk.CardUsing},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:getMark("_zhonger_st_heg__botu-turn") > 0
  end,
  on_use = function(self, event, target, player, data)
    data.disresponsiveList = data.disresponsiveList or {}
    local room = player.room
    for _, target in ipairs(room.alive_players) do
      if target:getMark("@@zhonger_st_heg__botu_dr-turn") > 0 then
        table.insertIfNeed(data.disresponsiveList, target.id)
        room:setPlayerMark(target, "@@zhonger_st_heg__botu_dr-turn", 0)
      end
    end
    room:setPlayerMark(player, "_zhonger_st_heg__botu-turn", 0)
  end,
}
botu:addRelatedSkill(zhonger_st_heg__botu_dr)
lvmeng:addSkill(botu)
Fk:loadTranslationTable{
  ["zhonger_st_heg__lvmeng"] = "吕蒙",
  ["#zhonger_st_heg__lvmeng"] = "白衣渡江",
  ["illustrator:zhonger_st_heg__lvmeng"] = "樱花闪乱",
  ["$hs__keji_zhonger_st_heg__lvmeng1"] = "谨慎为妙。",
  ["$hs__keji_zhonger_st_heg__lvmeng2"] = "时机未到。",
  ["$zhonger_st_heg__botu1"] = "厚积而薄发。",
  ["$zhonger_st_heg__botu2"] = "我胸怀的是这天下！",
  ["zhonger_st_heg__botu"] = "攻心",
  [":zhonger_st_heg__botu"] = "出牌阶段限一次，你可观看一名其他角色的手牌，然后你可展示其中一张牌并选择一项：1. 你弃置其此牌；2. 将此牌置于牌堆顶，然后若其手牌中花色数因此减少，其不能响应你本回合使用的下一张牌。",
  ["zhonger_st_heg__botu_discard"] = "弃置所选牌",
  ["zhonger_st_heg__botu_put"] = "将所选牌置于牌堆顶",
  ["#zhonger_st_heg__botu-ask"] = "攻心：观看%dest的手牌，可展示其中一张牌并选择一项",
  ["@@zhonger_st_heg__botu_dr-turn"] = "攻心",
  ["#zhonger_st_heg__botu_dr"] = "攻心",
  ["~zhonger_st_heg__lvmeng"] = "以后，就交给年轻人了。",
}

local huanggai = General(extension, "zhonger_st_heg__huanggai", "wu", 4)
huanggai:addSkill("hs__kurou")
huanggai:addCompanions("zhonger_st_heg__zhouyu")

Fk:loadTranslationTable{
  ["zhonger_st_heg__huanggai"] = "黄盖",
  ["#zhonger_st_heg__huanggai"] = "轻身为国",
  ["illustrator:zhonger_st_heg__huanggai"] = "G.G.G.",
  ["~zhonger_st_heg__huanggai"] = "盖，有负公瑾重托……",
}

local zhouyu = General(extension, "zhonger_st_heg__zhouyu", "wu", 3)
zhouyu:addSkill("ex__yingzi")
zhouyu:addSkill("ex__fanjian")
zhouyu:addCompanions("zhonger_st_heg__xiaoqiao")
Fk:loadTranslationTable{
  ["zhonger_st_heg__zhouyu"] = "周瑜",
  ["#zhonger_st_heg__zhouyu"] = "大都督",
  ["illustrator:zhonger_st_heg__zhouyu"] = "绘聚艺堂",
  ["~zhonger_st_heg__zhouyu"] = "既生瑜，何生亮。既生瑜，何生亮！",
}

local daqiao = General(extension, "zhonger_st_heg__daqiao", "wu", 3, 3, General.Female)
daqiao:addSkill("ex__guose")
daqiao:addSkill("liuli")
daqiao:addCompanions("zhonger_st_heg__xiaoqiao")

Fk:loadTranslationTable{
  ["zhonger_st_heg__daqiao"] = "大乔",
  ["#zhonger_st_heg__daqiao"] = "矜持之花",
  ["illustrator:zhonger_st_heg__daqiao"] = "佚名",
  ["~zhonger_st_heg__daqiao"] = "伯符，我去了……",
}

local luxun = General(extension, "zhonger_st_heg__luxun", "wu", 3)
local lianying = fk.CreateTriggerSkill{
  name = "zhonger_st_heg__lianying",
  anim_type = "drawcard",
  events = {fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    if not (player:hasSkill(self) and player:isKongcheng()) then return false end
    if player.phase ~= Player.NotActive then return false end
    for _, move in ipairs(data) do
      if move.from == player.id then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerHand then
            return true
          end
        end
      end
    end
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local n = 0
    for _, move in ipairs(data) do
      if move.from == player.id then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerHand then
            n = n + 1
          end
        end
      end
    end
    local players = room:askForChoosePlayers(player, table.map(room.alive_players, Util.IdMapper), 1, n, "#zhonger_st_heg__lianying-invoke:::"..n, self.name)
    if #players > 0 then
      self.cost_data = players
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targets = self.cost_data
    room:sortPlayersByAction(targets)
    for _, pid in ipairs(targets) do
      local p = room:getPlayerById(pid)
      if player.phase ~= Player.NotActive then return false end
      if not p.dead then p:drawCards(1, self.name) end
    end
  end,
}
local duoshi = fk.CreateViewAsSkill{
  name = "zhonger_st_heg__duoshi",
  anim_type = "drawcard",
  pattern = "await_exhausted",
  card_filter = function(self, to_select, selected)
    return #selected == 0 and Fk:getCardById(to_select).color == Card.Red and Fk:currentRoom():getCardArea(to_select) == Player.Hand
  end,
  view_as = function(self, cards)
    if #cards ~= 1 then
      return nil
    end
    local c = Fk:cloneCard("await_exhausted")
    c.skillName = self.name
    c:addSubcard(cards[1])
    return c
  end,
  enabled_at_play = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryTurn) < 1
  end,
}
lianying:addRelatedSkill(duoshi)
luxun:addSkill(lianying)
luxun:addSkill("hs__qianxun")
Fk:loadTranslationTable{
  ["zhonger_st_heg__luxun"] = "陆逊",
  ["#zhonger_st_heg__luxun"] = "擎天之柱",
  ["illustrator:zhonger_st_heg__luxun"] = "KayaK",
  ["zhonger_st_heg__duoshi"] = "度势",
  [":zhonger_st_heg__duoshi"] = "你可以将一张红色手牌当【以逸待劳】使用。",
  ["zhonger_st_heg__lianying"] = "度势",
  [":zhonger_st_heg__lianying"] = "出牌阶段限一次，你可将一张红色手牌当【以逸待劳】使用。你的回合外，当你失去手牌后，若你没有手牌，则你可以令至多X名角色各摸一张牌（X为你此次失去的手牌数）。",
  ["#zhonger_st_heg__lianying-invoke"] = "度势：你可令至多%arg名角色摸一张牌",
  ["#zhonger_st_heg__qianxun_delay"] = "谦逊",
  ["$hs__qianxun_zhonger_st_heg__luxun1"] = "满招损，谦受益。",
  ["$hs__qianxun_zhonger_st_heg__luxun2"] = "谦谦君子，温润如玉。",
  ["$zhonger_st_heg__lianying1"] = "生生不息，源源不绝。",
  ["$zhonger_st_heg__lianying2"] = "失之淡然，得之坦然。",
  ["~zhonger_st_heg__luxun"] = "我的未竟之业……",
}

local sunshangxiang = General(extension, "zhonger_st_heg__sunshangxiang", "wu", 3, 3, General.Female)
local xiaoji = fk.CreateTriggerSkill{
  name = "zhonger_st_heg__xiaoji",
  anim_type = "drawcard",
  events = {fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return end
    for _, move in ipairs(data) do
      if move.from == player.id then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerEquip then
            return true
          end
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    if player.room.current == player then
      player:drawCards(1, self.name)
    else
      player:drawCards(1, self.name)
    end
  end,
}
local ass = fk.CreateTriggerSkill{
  name = "ass",
  anim_type = "drawcard",
  events = {fk.CardUsing},
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return false end
    if event == fk.CardUsing then return player:hasSkill(self) and data.card.type == Card.TypeEquip and player == target
    else
    return player:hasSkill(self) and #p:getCardIds(Player.Equip) > 0 end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if event == fk.CardUsing then
      return room:askForSkillInvoke(target, self.name, nil, "#ass-invoke")
    end
      if #target > 0 then
        self.cost_data = target[1]
        return true
      end
  end,
  on_use = function(self, event, target, player, data)
    if event == fk.CardUsing then
      if target:hasSkill(self) then target:drawCards(1, self.name) end
    end
  end
}
xiaoji:addRelatedSkill(ass)
sunshangxiang:addSkill(xiaoji)
sunshangxiang:addSkill("jieyin")

Fk:loadTranslationTable{
  ["zhonger_st_heg__sunshangxiang"] = "孙尚香",
  ["#zhonger_st_heg__sunshangxiang"] = "弓腰姬",
  ["zhonger_st_heg__xiaoji"] = "枭姬",
  ["ass"] = "枭姬",
  ["#ass-invoke"] = "你可摸一张牌",
  [":zhonger_st_heg__xiaoji"] = "当你失去装备区里的牌后，或当你于出牌阶段使用装备牌后，你可以摸一张牌。",
  ["$zhonger_st_heg__xiaoji1"] = "弓马何须忌红妆？",
  ["$zhonger_st_heg__xiaoji2"] = "双剑夸巧，不让须眉！",
  ["$jieyin_zhonger_st_heg__sunshangxiang1"] = "随夫嫁娶，宜室宜家。",
  ["$jieyin_zhonger_st_heg__sunshangxiang2"] = "得遇夫君，妾身福分。",
  ["illustrator:zhonger_st_heg__sunshangxiang"] = "Thinking",
  ["~zhonger_st_heg__sunshangxiang"] = "不！还不可以死！",
}

local sunjian = General:new(extension, "zhonger_st_heg__sunjian", "wu", 5)
sunjian:addSkill("yinghun")
sunjian:addSkill("ol_ex__wulie")
Fk:loadTranslationTable{
  ['zhonger_st_heg__sunjian'] = '孙坚',
  ["#zhonger_st_heg__sunjian"] = "魂佑江东",
  ["illustrator:zhonger_st_heg__sunjian"] = "LiuHeng",
  ["~zhonger_st_heg__sunjian"] = "有埋伏！呃……啊！！",
}

local xiaoqiao = General(extension, "zhonger_st_heg__xiaoqiao", "wu", 3, 3, General.Female)
xiaoqiao:addSkill("ol_ex__tianxiang")
xiaoqiao:addSkill("hongyan")

Fk:loadTranslationTable{
  ['zhonger_st_heg__xiaoqiao'] = '小乔',
  ["#zhonger_st_heg__xiaoqiao"] = "矫情之花",
  ["illustrator:zhonger_st_heg__xiaoqiao"] = "绘聚艺堂",
  ["~zhonger_st_heg__xiaoqiao"] = "公瑾…我先走一步……",
}

local taishici = General(extension, "zhonger_st_heg__taishici", "wu", 4)
taishici:addSkill("tianyi")
Fk:loadTranslationTable{
  ['zhonger_st_heg__taishici'] = '太史慈',
  ["#zhonger_st_heg__taishici"] = "笃烈之士",
  ["illustrator:zhonger_st_heg__taishici"] = "Tuu.",
  ["~zhonger_st_heg__taishici"] = "大丈夫，当带三尺之剑，立不世之功！",
}

local zhoutai = General(extension, "zhonger_st_heg__zhoutai", "wu", 4)
local zhonger_st_heg__buqu = fk.CreateTriggerSkill{
  name = "zhonger_st_heg__buqu",
  frequency = Skill.Compulsory,
  events = {fk.HpLost},
  on_trigger = function(self, event, target, player, data)
    for i = 1, data.num do
      if player.shield >= 5 or not player:hasSkill(self) then break end
      self:doCost(event, target, player, data)
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:changeShield(player, 2)
  end,
}
zhoutai:addSkill(zhonger_st_heg__buqu)
local fenji = fk.CreateTriggerSkill{
  name = "zhonger_st_heg__fenji",
  anim_type = "support",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target.phase == Player.Finish and target == player
  end,
  on_use = function(self, event, target, player, data)
    target:drawCards(1, self.name)
    if not player.dead then player.room:loseHp(player, 1, self.name) end
  end,
}
zhoutai:addSkill(fenji)

Fk:loadTranslationTable{
  ['zhonger_st_heg__zhoutai'] = '周泰',
  ["#zhonger_st_heg__zhoutai"] = "历战之躯",
  ["zhonger_st_heg__buqu"] = "不屈",
  [":zhonger_st_heg__buqu"] = "当你失去1点体力时，你获得两点护甲。",
  ["$zhonger_st_heg__buqu1"] = "战如熊虎，不惜躯命！",
  ["$zhonger_st_heg__buqu2"] = "哼，这点小伤算什么！",
  ["illustrator:zhonger_st_heg__zhoutai"] = "Thinking",
  ["zhonger_st_heg__fenji"] = "奋激",
  [":zhonger_st_heg__fenji"] = "结束阶段，你可以摸一张牌，然后失去1点体力。",
  ["$zhonger_st_heg__fenji1"] = "百战之身，奋勇驱前！",
  ["$zhonger_st_heg__fenji2"] = "两肋插刀，愿赴此躯！",
  ["~zhonger_st_heg__zhoutai"] = "敌众我寡，无力回天……",
}

local lusu = General(extension, "zhonger_st_heg__lusu", "wu", 3)
lusu:addSkill("haoshi")
lusu:addSkill("dimeng")
Fk:loadTranslationTable{
  ['zhonger_st_heg__lusu'] = '鲁肃',
  ["#zhonger_st_heg__lusu"] = "独断的外交家",
  ["illustrator:zhonger_st_heg__lusu"] = "LiuHeng",
  ["~zhonger_st_heg__lusu"] = "此联盟已破，吴蜀休矣。",
}

local erzhang = General(extension, "zhonger_st_heg__zhangzhaozhanghong", "wu", 3)
erzhang:addSkill("zhijian")
erzhang:addSkill("guzheng")
Fk:loadTranslationTable{
  ['zhonger_st_heg__zhangzhaozhanghong'] = '张昭张纮',
  ["#zhonger_st_heg__zhangzhaozhanghong"] = "经天纬地",
  ["illustrator:zhonger_st_heg__zhangzhaozhanghong"] = "废柴男",
  ["~zhonger_st_heg__zhangzhaozhanghong"] = "竭力尽智，死而无憾。",
}

local dingfeng = General(extension, "zhonger_st_heg__dingfeng", "wu", 4)
dingfeng:addSkill("duanbing")
dingfeng:addSkill("ol__fenxun")
Fk:loadTranslationTable{
  ["zhonger_st_heg__dingfeng"] = "丁奉",
  ["#zhonger_st_heg__dingfeng"] = "清侧重臣",
  ["illustrator:zhonger_st_heg__dingfeng"] = "魔鬼鱼",
  ["$duanbing1"] = "众将官，短刀出鞘。",
  ["$duanbing2"] = "短兵轻甲也可取汝性命！",
  ["~zhonger_st_heg__dingfeng"] = "这风，太冷了……",
}

local huatuo = General(extension, "zhonger_st_heg__huatuo", "qun", 3)
huatuo:addSkill("jijiu")
huatuo:addSkill("hs__chuli")

Fk:loadTranslationTable{
  ["zhonger_st_heg__huatuo"] = "华佗",
  ["#zhonger_st_heg__huatuo"] = "神医",
  ["illustrator:zhonger_st_heg__huatuo"] = "琛·美弟奇",
  ["~zhonger_st_heg__huatuo"] = "生老病死，命不可违。",
}

local lvbu = General(extension, "zhonger_st_heg__lvbu", "qun", 5)
lvbu:addSkill("wushuang")
lvbu:addCompanions("zhonger_st_heg__diaochan")

Fk:loadTranslationTable{
  ["zhonger_st_heg__lvbu"] = "吕布",
  ["#zhonger_st_heg__lvbu"] = "武的化身",
  ["illustrator:zhonger_st_heg__lvbu"] = "DH",
  ["~zhonger_st_heg__lvbu"] = "不可能！",
}

local diaochan = General(extension, "zhonger_st_heg__diaochan", "qun", 3, 3, General.Female)
diaochan:addSkill("hs__lijian")
diaochan:addSkill("ex__biyue")

Fk:loadTranslationTable{
  ["zhonger_st_heg__diaochan"] = "貂蝉",
  ["#zhonger_st_heg__diaochan"] = "绝世的舞姬",
  ["illustrator:zhonger_st_heg__diaochan"] = "LiuHeng",
  ["~zhonger_st_heg__diaochan"] = "父亲大人，对不起……",
}

local yuanshao = General(extension, "zhonger_st_heg__yuanshao", "qun", 4)
yuanshao:addSkill("hs__luanji")
yuanshao:addCompanions("zhonger_st_heg__yanliangwenchou")

Fk:loadTranslationTable{
  ["zhonger_st_heg__yuanshao"] = "袁绍",
  ["#zhonger_st_heg__yuanshao"] = "高贵的名门",
  ["illustrator:zhonger_st_heg__yuanshao"] = "北辰菌",
  ["~zhonger_st_heg__yuanshao"] = "老天不助我袁家啊！",
}

local sx = General(extension, 'zhonger_st_heg__yanliangwenchou', 'qun', 4)
sx:addSkill('shuangxiong')
Fk:loadTranslationTable{
  ['zhonger_st_heg__yanliangwenchou'] = '颜良文丑',
  ["#zhonger_st_heg__yanliangwenchou"] = "虎狼兄弟",
  ["illustrator:zhonger_st_heg__yanliangwenchou"] = "KayaK",

  ["~zhonger_st_heg__yanliangwenchou"] = "这红脸长须大将是……",
}

local jiaxu = General(extension, 'zhonger_st_heg__jiaxu', 'qun', 3)
jiaxu:addSkill('wansha')
jiaxu:addSkill('luanwu')
jiaxu:addSkill("hs__weimu")
Fk:loadTranslationTable{
  ['zhonger_st_heg__jiaxu'] = '贾诩',
  ["#zhonger_st_heg__jiaxu"] = "冷酷的毒士",
  ["illustrator:zhonger_st_heg__jiaxu"] = "绘聚艺堂",
  ["~zhonger_st_heg__jiaxu"] = "我的时辰也到了……",
}

local pangde = General(extension, "zhonger_st_heg__pangde", "qun", 4)
pangde:addSkill("mashu")
pangde:addSkill("jianchu")

Fk:loadTranslationTable{
  ["zhonger_st_heg__pangde"] = "庞德",
  ["#zhonger_st_heg__pangde"] = "人马一体",
  ["illustrator:zhonger_st_heg__pangde"] = "凝聚永恒",
  ["~zhonger_st_heg__pangde"] = "四面都是水……我命休矣。",
}

local zhangjiao = General(extension, "zhonger_st_heg__zhangjiao", 'qun', 3)
local zhonger_st_heg__leiji = fk.CreateTriggerSkill{
  name = "zhonger_st_heg__leiji",
  anim_type = "offensive",
  events = {fk.CardUsing, fk.CardResponding, fk.FinishJudge},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and target == player then
      if event == fk.CardUsing or event == fk.CardResponding then
        return data.card.trueName == "jink" or data.card.trueName == "lightning"
      elseif event == fk.FinishJudge then
        return data.card.color == Card.Black
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    if event == fk.CardUsing or event == fk.CardResponding then
      return player.room:askForSkillInvoke(player, self.name)
    elseif event == fk.FinishJudge then
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.CardUsing or event == fk.CardResponding then
      local judge = {
        who = player,
        reason = self.name,
      }
      room:judge(judge)
    elseif event == fk.FinishJudge then
      local x = 2
      if data.card.suit == Card.Club then
        x = 1
        if player.dead then return false end
      end
      local targets = room:askForChoosePlayers(player, table.map(room:getOtherPlayers(player, false), Util.IdMapper), 1, 1,
      "#zhonger_st_heg__leiji-choose:::" .. x, self.name, true)
      if #targets > 0 then
        local tar = targets[1]
        room:damage{
          from = player,
          to = room:getPlayerById(tar),
          damage = x,
          damageType = fk.ThunderDamage,
          skillName = self.name,
        }
      end
    end
end,
}
zhangjiao:addSkill(zhonger_st_heg__leiji)
zhangjiao:addSkill("guidao")
Fk:loadTranslationTable{
  ['zhonger_st_heg__zhangjiao'] = '张角',
  ["#zhonger_st_heg__zhangjiao"] = "天公将军",
  ["illustrator:zhonger_st_heg__zhangjiao"] = "官方",
  ["zhonger_st_heg__leiji"] = "雷击",
  [":zhonger_st_heg__leiji"] = "①当你使用或打出【闪】或【闪电】时，你可判定。②当你的判定结果确定后，若结果为：黑桃，你可对一名其他角色造成2点雷电伤害；梅花，你回复1点体力。",
  ["$zhonger_st_heg__leiji1"] = "云涌风起，雷电聚集！",
  ["$zhonger_st_heg__leiji2"] = "乾坤无极，风雷受命！",
  ["$guidao_zhonger_st_heg__zhangjiao1"] = "世间万法，殊途同归！",
  ["$guidao_zhonger_st_heg__zhangjiao2"] = "从无邪恶之法，唯有作恶之人！",
  ["~zhonger_st_heg__zhangjiao"] = "只叹未能覆汉，徒失天时。",
}

local caiwenji = General(extension, "zhonger_st_heg__caiwenji", "qun", 3, 3, General.Female)
caiwenji:addSkill("beige")
caiwenji:addSkill("hs__duanchang")
Fk:loadTranslationTable{
  ["zhonger_st_heg__caiwenji"] = "蔡文姬",
  ["#zhonger_st_heg__caiwenji"] = "异乡的孤女",
  ["illustrator:zhonger_st_heg__caiwenji"] = "SoniaTang",
  ["~zhonger_st_heg__caiwenji"] = "人生几何时，怀忧终年岁。",
}

local mateng = General(extension, "zhonger_st_heg__mateng", "qun", 4)

local xiongyi = fk.CreateActiveSkill{
  name = "xiongyii",
  anim_type = "drawcard",
  frequency = Skill.Limited,
  card_num = 0,
  target_num = 0,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  card_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local targets = table.map(table.filter(room.alive_players, function(p) return H.compareKingdomWith(p, player) end), Util.IdMapper)
    room:sortPlayersByAction(targets)
    for _, p in ipairs(targets) do
      p = room:getPlayerById(p)
      if not p.dead then
        p:drawCards(2, self.name)
      end
    end
    if player.dead or player.kingdom == "unknown" then return false end
    local kingdomMapper = H.getKingdomPlayersNum(room)
    local num = kingdomMapper[H.getKingdom(player)]
    for _, n in pairs(kingdomMapper) do
      if n < num then return false end
    end
    local choices = {"hs__tieqi"}
    if #choices > 0 then
      local choice = player.room:askForChoice(player, choices, self.name, "#xiongyii-choice", true)
      player.room:handleAddLoseSkills(player, choice, nil)
    end
  end,
}

mateng:addSkill("mashu")
mateng:addSkill(xiongyi)
mateng:addRelatedSkill("hs__tieqi")

Fk:loadTranslationTable{
  ["zhonger_st_heg__mateng"] = "马腾",
  ["#zhonger_st_heg__mateng"] = "驰骋西陲",
  ["desinger:zhonger_st_heg__mateng"] = "淬毒",
  ["illustrator:zhonger_st_heg__mateng"] = "DH",
  ["xiongyii"] = "雄异",
  [":xiongyii"] = "限定技，出牌阶段，你可令与你势力相同的所有角色各摸两张牌，然后若你的势力角色数为全场最少，你获得“铁骑”。",
  ["$xiongyii1"] = "弟兄们，我们的机会来啦！",
  ["$xiongyii2"] = "此时不战，更待何时！",
  ["~zhonger_st_heg__mateng"] = "儿子，为爹报仇啊！",
}

local kongrong = General(extension, "zhonger_st_heg__kongrong", "qun", 3)
kongrong:addSkill("mobile__mingshi")
kongrong:addSkill("mobile__lirang")

Fk:loadTranslationTable{
  ["zhonger_st_heg__kongrong"] = "孔融",
  ["#zhonger_st_heg__kongrong"] = "凛然重义",
  ["desinger:zhonger_st_heg__kongrong"] = "淬毒",
  ["illustrator:zhonger_st_heg__kongrong"] = "苍月白龙",
  ["~zhonger_st_heg__kongrong"] = "覆巢之下，岂有完卵……",
}

local jiling = General(extension, "zhonger_st_heg__jiling", "qun", 4)

local shuangren = fk.CreateTriggerSkill{
  name = "shuangrenn",
  anim_type = "offensive",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and player.phase == Player.Play and not player:isKongcheng() and table.find(player.room:getOtherPlayers(player), function(p)
      return not p:isKongcheng()
    end)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local availableTargets = table.map(
      table.filter(room:getOtherPlayers(player), function(p)
        return not p:isKongcheng()
      end),
      Util.IdMapper
    )
    if #availableTargets == 0 then return false end
    local target = room:askForChoosePlayers(player, availableTargets, 1, 1, "#shuangrenn-ask", self.name, true)
    if #target > 0 then
      self.cost_data = target[1]
      return true
    end
    return false
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local target = room:getPlayerById(self.cost_data)
    local pindian = player:pindian({target}, self.name)
    if pindian.results[target.id].winner == player then
      if player.dead then return end
      local slash = Fk:cloneCard("slash")
      if player:prohibitUse(slash) then return false end
      local availableTargets = table.map(
        table.filter(room:getOtherPlayers(player), function(p)
          return H.compareKingdomWith(p, target) and not player:isProhibited(p, slash)
        end),
        Util.IdMapper
      )
      if #availableTargets == 0 then return false end
      local victims = room:askForChoosePlayers(player, availableTargets, 1, 1, "#shuangren_slash-ask:" .. target.id, self.name, false)
      if #victims > 0 then
        local to = room:getPlayerById(victims[1])
        if to.dead then return false end
        room:useVirtualCard("slash", nil, player, {to}, self.name, true)
      end
    else
      room:setPlayerMark(player, "shuangrenn-turn", 1)
    end
  end,
}

local shuangren_prohibit = fk.CreateProhibitSkill{
  name = "#shuangrenn_prohibit",
  is_prohibited = function(self, from, to, card)
    if from:hasSkill(self) then
      return from:getMark("shuangrenn-turn") > 0 and from ~= to
    end
  end,
}

shuangren:addRelatedSkill(shuangren_prohibit)
jiling:addSkill(shuangren)

Fk:loadTranslationTable{
  ["zhonger_st_heg__jiling"] = "纪灵",
  ["#zhonger_st_heg__jiling"] = "仲家的主将",
  ["illustrator:zhonger_st_heg__jiling"] = "樱花闪乱",
  ["desinger:zhonger_st_heg__jiling"] = "淬毒",

  ["shuangrenn"] = "双刃",
  [":shuangrenn"] = "出牌阶段开始时，你可与一名角色拼点。若你：赢，你视为对与其势力相同的一名角色使用【杀】；没赢，其他角色于此回合内不是你使用牌的合法目标。",

  ["#shuangrenn-ask"] = "双刃：你可与一名角色拼点",
  ["#shuangrenn_slash-ask"] = "双刃：你视为对与 %src 势力相同的一名角色使用【杀】",

  ["$shuangrenn1"] = "仲国大将纪灵在此！",
  ["$shuangrenn2"] = "吃我一记三尖两刃刀！",
  ["~zhonger_st_heg__jiling"] = "额，将军为何咆哮不断……",
}

local tianfeng = General(extension, "zhonger_st_heg__tianfeng", "qun", 3)

local sijian = fk.CreateTriggerSkill{
  name = "sijiann",
  events = {fk.AfterCardsMove},
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) or not player:isKongcheng() then return end
    local ret = false
    for _, move in ipairs(data) do
      if move.from == player.id then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerHand then
            ret = true
            break
          end
        end
      end
    end
    if ret then
      return table.find(player.room.alive_players, function(p) return not p:isNude() end)
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.map(table.filter(room.alive_players, function(p) return not p:isNude() end), Util.IdMapper)
    local target = room:askForChoosePlayers(player, targets, 1, 1, "#sijian-ask", self.name, true)
    if #target > 0 then
      self.cost_data = target[1]
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data)
    local id = room:askForCardChosen(player, to, "he", self.name)
    room:throwCard({id}, self.name, to, player)
  end,
}

local hs__sijian = fk.CreateTriggerSkill{
  name = "hs__sijian",
  anim_type = "control",
  events = {fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return end
    local room = player.room
    for _, move in ipairs(data) do
      if move.from == player.id then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerEquip then
            return table.find(room:getOtherPlayers(player), function(p)
              return not p:isNude()
            end) ~= nil
          end
        end
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room:getOtherPlayers(player), function(p)
      return not p:isNude()
    end)

    targets = table.map(targets, Util.IdMapper)
    local pid = room:askForChoosePlayers(player, targets, 1, 1, '#hs__sijian-discard',
      self.name, true)[1]

    if pid then
      self.cost_data = pid
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data)
    local id = room:askForCardChosen(player, to, "he", self.name)
    room:throwCard(id, self.name, to, player)
  end,
}


local suishi = fk.CreateTriggerSkill{
  name = "suishii",
  frequency = Skill.Compulsory,
  events = {fk.EnterDying, fk.Death},
  mute = true,
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) or target == player then return false end
    if event == fk.EnterDying then
      return data.damage and data.damage.from and H.compareKingdomWith(data.damage.from, player)
    else
      return H.compareKingdomWith(target, player)
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.EnterDying then
      room:notifySkillInvoked(player, self.name, "drawcard")
      player:broadcastSkillInvoke(self.name, 1)
      player:drawCards(1, self.name)
    else
      room:notifySkillInvoked(player, self.name, "negative")
      player:broadcastSkillInvoke(self.name, 2)
      if player:isKongcheng() then
        room:loseHp(player, 1, self.name)
      else
        room:askForDiscard(player, 1, 1, true, self.name, false)
      end
    end
  end,
}
sijian:addRelatedSkill(hs__sijian)
tianfeng:addSkill(sijian)
tianfeng:addSkill(suishi)

Fk:loadTranslationTable{
  ["zhonger_st_heg__tianfeng"] = "田丰",
  ["#zhonger_st_heg__tianfeng"] = "河北瑰杰",
  ["illustrator:zhonger_st_heg__tianfeng"] = "地狱许",
  ["desinger:zhonger_st_heg__tianfeng"] = "淬毒",
  ["hs__sijian"] = "死谏",
  ["sijiann"] = "死谏",
  [":sijiann"] = "当你失去最后的手牌后，或当你失去装备区里的牌后，你可弃置一名其他角色的一张牌。",
  ["suishii"] = "随势",
  [":suishii"] = "锁定技，①当其他角色因受到伤害而进入濒死状态时，若来源与你势力相同，你摸一张牌；②当其他角色死亡时，若其与你势力相同，你弃置一张牌，若你没有手牌则改为失去1点体力。",
  ["suishi_choice1"] = "弃置一张牌",
  ["suishi_choice2"] = "失去1点体力",
  ["#hs__sijian-discard"] = "死谏：你可弃置一名其他角色的一张牌",
  ["#sijian-ask"] = "死谏：你可弃置一名其他角色的一张牌",
  ["$sijiann2"] = "忠言逆耳啊！！",
  ["$sijiann1"] = "且听我最后一言！",
  ["$suishii1"] = "一荣俱荣！",
  ["$suishii2"] = "一损俱损……",
  ["~zhonger_st_heg__tianfeng"] = "不纳吾言而反诛吾心，奈何奈何！！",
}

local panfeng = General(extension, "zhonger_st_heg__panfeng", "qun", 4)
local kuangfu = fk.CreateTriggerSkill{
  name = "zhonger_st_heg__kuangfu",
  events = {fk.TargetSpecified},
  can_trigger = function (self, event, target, player, data)
    if player:hasSkill(self) and data.card and data.card.trueName == "slash" and player.phase == Player.Play and player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 then
      for _, p in ipairs(AimGroup:getAllTargets(data.tos)) do
        if #player.room:getPlayerById(p):getCardIds(Player.Equip) > 0 then
          return true
        end
      end
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local choice = {}
    for _ , choicePlayers in ipairs(AimGroup:getAllTargets(data.tos)) do
       if #room:getPlayerById(choicePlayers):getCardIds("e") > 0 then
        table.insert(choice, choicePlayers)
      end
    end
    local p = room:askForChoosePlayers(player, choice, 1, 1, "#zhonger_st_heg__kuangfu-choice", self.name, true)
    if #p == 0 then return end
    local card = room:askForCardChosen(player, room:getPlayerById(p[1]), "e", self.name)
    room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonPrey, self.name, nil, false, player.id)
    data.extra_data = data.extra_data or {}
    data.extra_data.zhonger_st_heg__kuangfuUser = player.id
  end,
}
local kuangfu = fk.CreateActiveSkill{
  name = "zhonger_st_heg__kuangfu",
  prompt = "#zhonger_st_heg__kuangfu-active",
  anim_type = "offensive",
  card_num = 0,
  target_num = 1,
  card_filter = Util.FalseFunc,
  target_filter = function(self, to_select, selected)
    return #selected == 0 and #Fk:currentRoom():getPlayerById(to_select).player_cards[Player.Equip] > 0
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = player
    local id = room:askForCardChosen(player, target, "e", self.name)
    room:throwCard({id}, self.name, target, player)
    if player.dead then return end
    local targets = {}
    local slash = Fk:cloneCard("slash")
    slash.skillName = self.name
    if player:prohibitUse(slash) then return end
    for _, p in ipairs(room.alive_players) do
      if p ~= player and not player:isProhibited(p, slash) then
        table.insert(targets, p.id)
      end
    end
    if #targets == 0 then return end
    local to = room:askForChoosePlayers(player, targets, 1, 1, "#ty__kuangfu-slash", self.name, false)
    local use = {
      from = player.id,
      tos = { to },
      card = slash,
      extraUse = false,
    }
    room:useCard(use)
    if player.dead then return end
  end,
}

panfeng:addSkill(kuangfu)
Fk:loadTranslationTable{
  ["zhonger_st_heg__panfeng"] = "潘凤",
  ["#zhonger_st_heg__panfeng"] = "联军上将",
  ["illustrator:zhonger_st_heg__panfeng"] = "游江",
  ["zhonger_st_heg__kuangfu"] = "狂斧",
  [":zhonger_st_heg__kuangfu"] = "出牌阶段，你可以弃置你装备区里的一张牌，视为使用一张无次数限制的【杀】。",
  ["#zhonger_st_heg__kuangfu-active"] = "发动 狂斧，弃置你装备区里的一张牌牌",
  ["#zhonger_st_heg__kuangfu-slash"] = "狂斧：选择视为使用【杀】的目标",
  ["$zhonger_st_heg__kuangfu1"] = "大斧到处，片甲不留！",
  ["$zhonger_st_heg__kuangfu2"] = "你可接得住我一斧？",
  ["~zhonger_st_heg__panfeng"] = "潘凤又被华雄斩啦！",
}
local zoushi = General(extension, "zhonger_st_heg__zoushi", "qun", 3, 3, General.Female)
local huoshui = fk.CreateTriggerSkill{ -- FIXME
  name = "zhonger_st_heg__huoshui",
  anim_type = "control",
  frequency = Skill.Compulsory,
  events = {fk.TurnStart, fk.GeneralRevealed, fk.EventAcquireSkill, fk.EventLoseSkill, fk.Deathed},
  can_trigger = function(self, event, target, player, data)
    if target ~= player or player.room.current ~= player then return false end
    if event == fk.TurnStart then
      return player:hasSkill(self)
    end
    if event == fk.EventAcquireSkill or event == fk.EventLoseSkill then
      return data == self
    elseif event == fk.GeneralRevealed then
      if player:hasSkill(self) then
        for _, v in pairs(data) do
          if table.contains(Fk.generals[v]:getSkillNameList(), self.name) then return true end
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if table.contains({fk.TurnStart, fk.GeneralRevealed, fk.EventAcquireSkill}, event) then
      local targets = {}
      for _, p in ipairs(room:getOtherPlayers(player)) do
        room:setPlayerMark(p, "@@huoshui-turn", 1)
        local record = U.getMark(p, MarkEnum.RevealProhibited .. "-turn")
        table.insertTable(record, {"m", "d"})
        room:setPlayerMark(p, MarkEnum.RevealProhibited .. "-turn", record)
        table.insert(targets, p.id)
      end
      room:doIndicate(player.id, targets)
    elseif event == fk.TargetSpecified then
      local targets = table.filter(room.alive_players, function(p) return (not H.compareKingdomWith(p, player)) and H.getGeneralsRevealedNum(p) == 1 end)
      if #targets > 0 then
        data.disresponsiveList = data.disresponsiveList or {}
        for _, p in ipairs(targets) do
          table.insertIfNeed(data.disresponsiveList, p.id)
        end
      end
    else
      for _, p in ipairs(room:getOtherPlayers(player)) do
        room:setPlayerMark(p, "@@huoshui-turn", 0)
        local record = U.getMark(p, MarkEnum.RevealProhibited .. "-turn")
        table.removeOne(record, "m")
        table.removeOne(record, "d")
        if #record == 0 then record = 0 end
        room:setPlayerMark(p, MarkEnum.RevealProhibited .. "-turn", record)
      end
    end
  end,
}
local huoshuii = fk.CreateTriggerSkill{
  name = "huoshuii",
  anim_type = "control",
  events = {fk.AfterCardUseDeclared},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and
      data.card.type == Card.TypeTrick and data.card.sub_type ~= Card.SubtypeDelayedTrick
  end,
  on_use = function(self, event, target, player, data)
    data.prohibitedCardNames = {"nullification"}
  end,
}
huoshui:addRelatedSkill(huoshuii)
zoushi:addSkill(huoshui)
zoushi:addSkill("ty__qingcheng")
Fk:loadTranslationTable{
  ["zhonger_st_heg__zoushi"] = "邹氏",
  ["zhonger_st_heg__huoshui"] = "祸水",
  ["huoshuii"] = "祸水",
  [":zhonger_st_heg__huoshui"] = "锁定技，你的非延时锦囊牌不可被【无懈可击】响应；你的回合内，其他角色不能明置其武将牌。",
  ["qingcheng"] = "倾城",
  [":qingcheng"] = "出牌阶段，你可弃置一张牌并选择一名武将牌均明置的其他角色，然后你暗置其一张武将牌。然后若你以此法弃置的牌是装备牌，则你可令其失去1点体力。",
  ["@@huoshui-turn"] = "祸水",
  ["$zhonger_st_heg__huoshui1"] = "嗯哼哼，走不动了吗？",
  ["$zhonger_st_heg__huoshui2"] = "别走了，再玩一会儿嘛~",
  ["~zhonger_st_heg__zoushi"] = "年老色衰了吗？",
}

return {card_extension, extension}
